/**
 * 函数防抖
 * @param {Function} fn
 * @param {Number} wait 毫秒数
 */
export function debounce(fn, wait) {
  let timer = null

  return function (...args) {
    if (timer !== null) {
      window.clearTimeout(timer)
    }

    timer = setTimeout(() => {
      fn.call(this, ...args)
      timer = null
    }, wait)
  }
}
